import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.InputEvent;

import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.KeyStroke;


public class Menuebar extends JMenuBar implements ActionListener{
	 /** advSet zeigt die extraoptionen an */
	 Advanced_Settings advSet;
	
	 /** die beiden hilfsfenster*/
	 private GeneralHelp generalHelp;
	 private SettingsHelp settingsHelp;
	
	 /* die zwei jMenus*/
	private JMenu file;
	private JMenu help;
	
	//**Items fuer file*/
	private JMenuItem settings;
	private JMenuItem exit;
	
	//**Items fuer help*/
	private JMenuItem generalInfo;
	private JMenuItem settingInfo;
	
	
	//* die antsimulation*/
	private AntSimulation as ;
	
	
	/**
	 * Konstruktor
	 * @param as
	 */
	public Menuebar(AntSimulation as){
		
		this.as=as;
		
		advSet=new Advanced_Settings(as);
		generalHelp=new GeneralHelp();
		settingsHelp=new SettingsHelp();
		
		file=new JMenu("File");
		help=new JMenu("Help");
		
		settings=new JMenuItem("Advanced Settings");
		settings.setAccelerator(KeyStroke.getKeyStroke("F3"));
		settings.addActionListener(this);
		exit=new JMenuItem("Exit");
		exit.setAccelerator(KeyStroke.getKeyStroke('Q', InputEvent.CTRL_DOWN_MASK));
		exit.addActionListener(this);
		
		generalInfo=new JMenuItem("General Information");
		generalInfo.setAccelerator(KeyStroke.getKeyStroke("F1"));
		generalInfo.addActionListener(this);
		settingInfo=new JMenuItem("Settings Information");
		settingInfo.setAccelerator(KeyStroke.getKeyStroke("F2"));
		settingInfo.addActionListener(this);
		
		file.add(settings);
		file.add(exit);
		
		help.add(generalInfo);
		help.add(settingInfo);
		
		this.add(file);
		this.add(help);
		
	}	
	
	/** falls auf item geklickt wird
	 * 
	 */
	
	
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		
		if(e.getSource()==generalInfo)
			
			generalHelp.getHelp();
		
		if(e.getSource()==settingInfo)
			settingsHelp.getHelp();
			//settingsHelp=new GeneralHelp(this,"SettingsHelp");
		
		
		if(e.getSource()==settings)
			advSet.getInstanz();
		
		if(e.getSource()==exit)
			System.exit(0);
		
	}


	
	
	

}
